<template>
  <PageWrapper contentFullHeight fixedHeight>
    <VxeBasicTable class="w-full h-full" ref="tableRef" v-bind="gridOptions">

    </VxeBasicTable>
    <RoleDrawer @register="registerDrawer" @success="reloadTableData" />
  </PageWrapper>
</template>

<script lang="ts" setup>
import { ref, reactive } from 'vue';
import { message } from "ant-design-vue";
import { Icon } from '@gui-pkg/components';
import { PageWrapper, BasicTableProps, VxeBasicTable, VxeGridInstance, useDrawer } from '@gui-pkg/antdcomponents';
import { columns, searchFormSchema } from './log.data';
import {getLogList} from "@/api/system/log";

defineOptions({ name: 'RoleManagement' });

const [registerDrawer, { openDrawer }] = useDrawer();
const tableRef = ref<VxeGridInstance>();
const gridOptions = reactive<BasicTableProps>({
  id: tableRef.value,
  keepSource: true,
  columns: columns,
  treeConfig: {
    children: 'children',
    indent: 20,
    showIcon: true,
    iconOpen: 'vxe-icon-square-minus',
    iconClose: 'vxe-icon-square-plus'
  },

  formConfig: {
    enabled: true,
    className: "vxe-formConfig",
    items: searchFormSchema,
  },
  height: 'auto',
  proxyConfig: {
    ajax: {
      query: async ({ page, form }) => {
        console.log('form',form);
        const tableListData = await getLogList({
          pageNum: page.currentPage,
          pageSize: page.pageSize,
          beginTime:form.operTime==null?"":form.operTime[0],
          endTime:form.operTime==null?"":form.operTime[1],
        });
       console.log('tableListDatatableListDatatableListDatatableListData',tableListData)
        return { list: tableListData.rows ,total:tableListData.total};
      },
    },
  },
});

function handleCreate() {
  openDrawer(true, {
    isUpdate: false,
  });
}

// 编辑用户资料
function handleEdit(row) {
  openDrawer(true, {
    record: row,
    isUpdate: true,
  });
}

</script>

